
export class Random {
  private num:number 
  constructor(num = 5) {
    this.num = num;
  }
  private getId(): number {
    const originArr = new Array(this.num);
    let idArr = [...originArr].map(() => Math.floor(Math.random() * 10)).sort(() => 0.5 - Math.random());
    let id = Number(idArr.join(''))
    return id;
  }
  public get id(): number {
    return this.getId()
  }
  async ID(cell: any): Promise<number> {
    let id = random.id;
    let data = await cell.find({ id }).toArray();
    if (data.length) id = random.id
    return id
  }
}
const random = new Random();
export async function getId(cell: any): Promise<number> {
  let id = random.id;
  let data = await cell.find({ id }).toArray();
  if (data.length) id = random.id
  return id
}